import request from '@/plugin/axios'
import util from '@/libs/util.js'
import axios from 'axios'

function createObjectURL(object) {
  return (window.URL) ? window.URL.createObjectURL(object) : window.webkitURL.createObjectURL(object);
}

export default {

	info (data) {
		return request({
			url: 'sysExportLog/get',
			headers: {},
			method: 'post',
			data,
		});
	},

	export (data) {
	    axios({
			method:'post',
			url: process.env.VUE_APP_API + 'sysExportLog/export',
			data: data,
			headers: {
			'Authorization': 'Bearer ' + util.cookies.get('token'),
			},
			responseType: 'blob',
	    })
	    .then(function(resp) {
			let blob = new Blob([resp.data], {
				type: 'application/octet-stream'
			});
			let blobUrl = window.URL.createObjectURL(blob);
			const a = document.createElement('a');
			a.style.display = 'none';
			a.download = data.fileName; //文件名
			a.href = blobUrl;
			a.click();
	    });
	},
};